package StreamDemo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Date: 2023-05-01
 * Time: 9:44
 */

public class Test {
    public static void main(String[] args) {

        // 过滤奇数,只留下偶数

        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list,1,2,3,4,5,6,7,8,9,10);

        List<Integer> collect = list.stream().filter(integer -> integer % 2 == 0).collect(Collectors.toList());

        System.out.println(collect);


    }
}
